const app = getApp()
Page({
  goLogin() {
    wx.navigateTo({
      url: '/pages/login/index',
    })
  },
  // data:{
  //   avatar:'',
  //   nickName:''
  // },
   async onShow(){
    // console.log(app.token);
    app.token&& await this.getUserProfile()
    app.userProfile={avatar:this.data.avatar, nickName:this.data.nickName}
    // console.log(app,'apppppp');
    // app.setUsers(this.data.nickName,this.data.avatar)
    // console.log(app.userProfile,'--------');
    
  },
  //那用户信息数据
  async getUserProfile(){
    const {code,data} = await wx.http.get('/userInfo')
    if(code!==10000) return wx.utils.toast()
    // console.log(data.nickName,'不对把');
    this.setData({
      avatar:data.avatar,
      nickName:data.nickName
    })
    // console.log(this.data.nickName,'不对把');
    // console.log(this.data.avatar,'不对把');

  }
})
